/**
 * 
 */
package com.kclmedu.forhelp.data;

import java.awt.Component;

import javax.swing.JCheckBox;
import javax.swing.JTable;
import javax.swing.table.DefaultTableCellRenderer;

import org.apache.log4j.Logger;

/**
 * 表格单元格的渲染器
 * @author yejf
 *
 */
public class MyCheckBoxRender extends DefaultTableCellRenderer {

	/**
	 * 
	 */
	private static final long serialVersionUID = -9039826860903308102L;
	
	private static final Logger LOGGER = Logger.getLogger(MyCheckBoxRender.class);
	
	public MyCheckBoxRender() {
		LOGGER.debug("...构造MyCheckBoxRender");
	}

	/* (non-Javadoc)
	 * @see javax.swing.table.TableCellRenderer#getTableCellRendererComponent(javax.swing.JTable, java.lang.Object, boolean, boolean, int, int)
	 */
	@Override
	public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, 
				boolean hasFocus, int row, int col) {
		LOGGER.debug(">>> getTableCellRendererComponent方法被调用了...");
		//进一步判断
		if(row == 0) {
//			System.out.println(">>>> 第一行，全是 复选框组件....");
			//先拿到单元格内组件
			JCheckBox jcb = (JCheckBox) value;
			LOGGER.debug("在getTableCellRendererComponent方法中Value的哈希码值："+jcb.hashCode());
			//
			LOGGER.debug("当前单元格内 JCheckBox["+jcb.getText()+"]的状态是："+jcb.isSelected());
			
			return jcb;
			
		} else {
			return super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, col);
		}
	}
}


